#!/bin/env ruby
# encoding: utf-8
require_relative '../spec/spec_helper'
require_relative '../spec/commons/user_auth'
require_relative '../spec/commons/date'
require_relative '../spec/commons/report'
require_relative '../spec/commons/check_pages'

#TODO что-то сделать с абсолютными ссылками в rangepicker
#TODO сдвинуть дату (кликаем ячейку таблицы). Проблема в изменении значения аттрибута
#  class 


describe 'Standard Report Page' do
  before {

	}
  context 'when logged in' do
  	it 'then he can work with standart report page' do
  	  goto 'http://pulse.7bits.it/en/login-page'
  	  user_signs_in()
  	  goto 'http://pulse.7bits.it/en/us/standard-reports'
  	  check_standard_report_page()
  	end
  end

  
  #TODO узнать как сделать активной дату из таблицы
  #TODO написать без абсолютных путей

  context 'when choose department' do
    it 'then all links builds correctly' do
      goto('http://pulse.7bits.it/en/us/standard-reports')	
      check_all_links()	
    end
  end

  context 'when work with calendars' do
    it 'daterangepickers give correct dates' do 
      text_field(class: "form-control input-sm js-reports-rangepicker", index: 0).click()
      check_interval(3,0,1).should be_truthy
      text_field(class: "form-control input-sm js-reports-rangepicker", index: 1).click()    
      check_interval(4,2,3).should be_truthy
      text_field(class: "form-control input-sm js-reports-rangepicker", index: 2).click()    
      check_interval(5,4,5).should be_truthy         
    end
  end 
  

  context 'when logged in' do
  	it 'then he can work with improvements filtered by benefit' do
	   goto('http://pulse.7bits.it/en/us/standard-reports')		  
	   test_for_links()       
    end
  end

  # context 'when change daterange interval' do
  #   it 'then input field takes correct date interval' do
  #    (check_input(0)).should be_truthy
  #    #check_input(1)
  #    #check_input(2)
  #   end
  # end

  context 'when logged in' do
    it 'then he can work with improvements filtered by requester' do
      goto('http://pulse.7bits.it/en/us/standard-reports')
      if (browser.text.include? 'filtered by requester') then check_req_links() end
    end
  end

  context 'when logged out' do
    it "then he can't work with standart report page"  do
	  user_logout()
    end
  end

end